export type IShapeType =
  | "rect"
  | "image"
  | "text"
  | "barcode"
  | "qrcode"
  | "d-text"
  | "d-image"
  | "d-video"
  | "d-barcode"
  | "d-qrcode";
export interface IDraggable {
  x: number;
  y: number;
  w: number;
  h: number;
  rotate: number;
  /* 矩形真实坐标 */
  originX: number;
  originY: number;
  /*  */
  minWidth: number;
  minHeight: number;
  maxWidth: number;
  maxHeight: number;
  /* 限制出界 */
  parent?: boolean;

  grid: number[];
  /* X轴 */
  axis?: "x" | "y" | "both";

  /* 允许拖拽 */
  draggable?: boolean;
  /* 允许旋转 */
  rotatable?: boolean;
  /* 允许调整 */
  resizable?: boolean;
  /* 层级 */
  z?: number;
  /* 唯一ID */
  id?: string;
  /* 禁用 */
  disabled?: boolean;
  /* 允许失焦 */
  preventDeactivation?: boolean;
  overflow: boolean;
  lockAspectRatio: boolean;
  className?: string;
  borderColor?: string;

  type: IShapeType;
  show: boolean;
}
export type HandleType =
  | "drag"
  /* 旋转 */
  | "rotation"
  | "rotation-tl"
  | "rotation-tr"
  | "rotation-bl"
  | "rotation-br"
  /* 调整大小 */
  | "resize-mr"
  | "resize-mb"
  | "resize-ml"
  | "resize-mt"
  | "resize-br"
  | "resize-bl"
  | "resize-tr"
  | "resize-tl";

export type Vertex2D = {
  x: number;
  y: number;
};

export interface IRect {
  w: number;
  h: number;
  x: number;
  y: number;
  rotate: number;
}
/* 边界 */
export interface Boundary {
  left: number;
  right: number;
  top: number;
  bottom: number;
}

export type MouseDirection = "top" | "bottom" | "left" | "right" | "tl" | "tr" | "bl" | "br";
export interface MouseRecord {
  /* 记录宽高的偏移量 */
  sw: number;
  sh: number;
  /* 记录坐标的偏移量 */
  sx: number;
  sy: number;
  startAngle: number;
  /* 顶点的偏移量,旋转顶点再拖拽时产生 */
  vx: number;
  vy: number;
  /* 真实偏移坐标 */
  rx: number;
  ry: number;
}
export type EmitKey =
  | "selected"
  | "resize"
  | "rotate"
  | "drag"
  | "dragStart"
  | "dragEnd"
  | "resizeStart"
  | "resizeEnd"
  | "rotateStart"
  | "rotateEnd"
  | "contextmenu";

export type KeyboardEventName = "ArrowLeft" | "ArrowRight" | "ArrowUp" | "ArrowDown";
export type KeyMapEvent = {
  [key in KeyboardEventName]: () => void;
};
export type VertexType = "left" | "top" | "bottom" | "right" | "origin";
export type EventParam = {
  el: HTMLElement | null;
  rect: IDraggable;
  behavior?: HandleType;
  mouseDirection?: MouseDirection;
};
export type TemporaryData = {
  behavior?: HandleType;
  mouseDirection?: MouseDirection;
};
export type IAuxiliaryLine = {
  width: number;
  height: number;
  left: number;
  top: number;
  id: string;
  direction: "left" | "top" | "bottom" | "right";
};
export interface IMatrix {
  a: number;
  b: number;
  c: number;
  d: number;
  x: number;
  y: number;
}
